package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        System.out.println("开始输入，输入exit退出！");
        Scanner s=new Scanner(System.in);
        FileOutputStream f=new FileOutputStream("note.txt",true);
        while (true){
            if ("exit".equals(s.nextLine())){
                System.out.println("输入结束！");
                break;
            }
            f.write(s.nextLine().getBytes(StandardCharsets.UTF_8));
            System.out.println("继续写入！");
        }
        f.close();
    }
}
//public class Test {
//    public static void main(String[] args) throws IOException {
//        FileOutputStream fos = new FileOutputStream("note.txt");
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("开始输入内容,单独输入exit退出");
//        while(true) {
//            String line = scanner.nextLine();
////            if(line.equals("exit")){
//            if("exit".equals(line)){
//                System.out.println("已退出");
//                break;
//            }
//            fos.write(line.getBytes(StandardCharsets.UTF_8));
//            System.out.println("输出入完毕");
//        }
//        fos.close();
//    }
//}
